package org.sjs.dreamfly.model

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore
import androidx.room.PrimaryKey
import androidx.room.Relation

@Entity(tableName = "video_info", foreignKeys = [
    ForeignKey(entity = MovieInfo::class,
        parentColumns = ["id"],
        childColumns = ["movieId"],
        onDelete = ForeignKey.CASCADE)])
data class VideoInfo(
    @PrimaryKey(autoGenerate = true)
    var id: Long = 0,
    var videoId: String = "",
    var videoUrl: String? = null,
    var title: String? = null,
    var refer: String? = null,
    var nextRefer: String? = null,
    var prevRefer: String? = null,
    var nextVideoUrl: String? = null,
    var movieId: String? = null,
    var videoType: String? = null,
    var cover: String? = null,
    var sid: Int = 1, // 第几季
    var nid: Int = 1, // 第几集
    var encrypt: Int = 0,
    var imageUrl: String? = null,
    @Ignore
    var parent: MovieInfo? = null,
) {
    constructor() : this(0, "", "", "", "", "", "", "", "", "", "", 0, 0, 0, "")
    override fun toString(): String {
        return "VideoInfo(videoUrl='$videoUrl', title='$title', refer=$refer, nextRefer=$nextRefer, prevRefer=$prevRefer, nextVideoUrl=$nextVideoUrl, movieId=$movieId, encrypt=$encrypt, imageUrl=$imageUrl)"
    }

//    fun isSame(videoInfo: VideoInfo): Boolean {
//        return (videoInfo.movieId == this.movieId &&
//                videoInfo.sid == this.sid &&
//                videoInfo.nid == this.nid)
//    }
}
